package com.yanma.erp;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.context.web.SpringBootServletInitializer;
import org.springframework.boot.orm.jpa.EntityScan;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;

/**
 * server 主入口
 * Created by Kenry.xian on 2015/1/16 0016.
 */
@Configuration //标明这个是SpringBoot的配置类，可以通过类配置代替原有的XML配置方式
@EnableAutoConfiguration //启动bean自动注入
@ComponentScan //启动自动搜索bean
@EntityScan //启动实体自动搜索
public class ServletMain extends SpringBootServletInitializer {
    public static void main(String[] args) throws Exception {
        SpringApplication.run(ServletMain.class);
        
    }

    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
        return application.sources(applicationClass);
    }

    private static Class<ServletMain> applicationClass = ServletMain.class;

//    @Override
//    public void addResourceHandlers(ResourceHandlerRegistry registry) {
//        registry.addResourceHandler("/down/*").addResourceLocations("classpath:/down/");
//    }

//    @Bean
//    public FilterRegistrationBean characterEncodingFilter() {
//        CharacterEncodingFilter filter = new CharacterEncodingFilter();
//        filter.setForceEncoding(true);
//        filter.setEncoding("UTF-8");
//        FilterRegistrationBean registration = new FilterRegistrationBean();
//        registration.setFilter(filter);
//        registration.setDispatcherTypes(EnumSet.allOf(DispatcherType.class));
//        registration.addUrlPatterns("/");
//        return registration;
//    }

//    public class WebInitializer extends SpringBootServletInitializer {
//        @Override
//        protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
//            return application.sources(Main.class);
//        }
//    }
}
